/* Copyright (c) 2008 Google Inc.
*  Copyright (c) 2009 Pierre Henri Kuate.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System.Collections.Generic;

public static class DisplayExtendedProfileData
{
    public static void Run()
    {
        var c = new org.opensocial.client.OpenSocialClient("orkut.com");

        c.setProperty(org.opensocial.client.OpenSocialClient.Properties.REST_BASE_URI,
                      "http://www.orkut.com/social/rest");
        c.setProperty(org.opensocial.client.OpenSocialClient.Properties.RPC_ENDPOINT, // Choosen by default
                      "http://www.orkut.com/social/rpc");

        // Credentials provided here are associated with the gadget located at
        // http://opensocial-resources.googlecode.com/svn/samples/rest_rpc/sample.xml;
        // If you install this gadget, you can substitute your own OpenSocial ID
        // for the one used below and fetch your profile data and friends
        c.setProperty(org.opensocial.client.OpenSocialClient.Properties.CONSUMER_SECRET, "uynAeXiWTisflWX99KU1D2q5");
        c.setProperty(org.opensocial.client.OpenSocialClient.Properties.CONSUMER_KEY, "orkut.com:623061448914");
        c.setProperty(org.opensocial.client.OpenSocialClient.Properties.VIEWER_ID, "03067092798963641994");

        // Create a new OpenSocialRequestParameterSet object to indicate which request
        // parameters you want to pass with your request; in this case, we are asking
        // orkut specifically to return the name and gender fields for the person
        // fetched below.
        var parameters = new Dictionary<string, org.opensocial.client.OpenSocialRequestParameter>();
        parameters.Add("fields", new org.opensocial.client.OpenSocialRequestParameter("gender", "name"));

        // Retrieve the profile data of the specified user using the OpenSocialClient
        // method fetchPerson; pass in the parameter set object created above
        var person = c.fetchPerson("03067092798963641994", parameters);

        System.Console.Out.WriteLine("----------");

        // Output the name, ID, and gender of the requested person
        System.Console.Out.WriteLine("ID: " + person.Id);
        System.Console.Out.WriteLine("Name: " + person.DisplayName);
        System.Console.Out.WriteLine("Gender: " + person.getField("gender").StringValue);

        System.Console.Out.WriteLine("----------");
    }
}